import {
  getRolePermissionList,
  addOneRolePermission,
  getRolePermissionByID,
  updateOneRolePermission,
  deleteOneRolePermission
} from '@/api/rolePermission'

const rolePermission = {
  state: {
  },

  mutations: {
  },

  actions: {
    // 查询角色权限列表
    getRolePermissionList({ commit }, condition) {
      return new Promise((resolve, reject) => {
        getRolePermissionList(condition).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 新增一个权限
    addOneRolePermission({ commit }, data) {
      return new Promise((resolve, reject) => {
        addOneRolePermission(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 根据id查询权限详情
    getRolePermissionByID({ commit }, id) {
      return new Promise((resolve, reject) => {
        getRolePermissionByID(id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 更新一个权限
    updateOneRolePermission({ commit }, data) {
      return new Promise((resolve, reject) => {
        updateOneRolePermission(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 更新一个权限
    deleteRolePermissionById({ commit }, id) {
      return new Promise((resolve, reject) => {
        deleteOneRolePermission(id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default rolePermission
